<?php

include './include/common.php';
if (empty ( $_COOKIE ['wcity']['id'] )) { //第一次访问，没有地区和cookie

	include SYSTEM_ROOTPATH . '/include/ipcha.php'; //模版编译类
		
	$myobj = new ipLocation();
	$IP = $myobj->get_IP();
	$address = $myobj->getaddress($IP );
	$myobj = NULL;
	$address["area1"]=mb_convert_encoding($address["area1"],"UTF-8","GBK" );
	$wordCity = $db->select ( "select `id`,`name`,`pinyin`,`Ab` from " . $table_top . "area where property=1" );


	foreach ( $wordCity as $v ) {
		if (strstr( $address ['area1'],$v['Ab'])) {
	
			
			SetCookie ( "wcity[pinyin]", $v ['pinyin'], time () + 600, "/", $SCRIPT_HOST );
			SetCookie ( "wcity[id]", $v ['id'], time () + 600, "/", $SCRIPT_HOST );
			SetCookie ( "wcity[name]", $v ['Ab'], time () + 600, "/", $SCRIPT_HOST );

			$_COOKIE ['wcity']['pinyin']=$v ['pinyin'];
			$_COOKIE ['wcity']['id']=$v ['id'];
			$_COOKIE ['wcity']['name']=$v ['Ab'];

			break;
		}
	}
}

		if (!$_COOKIE ['wcity']['name']) {
			SetCookie ( "wcity[pinyin]", $v ['pinyin'], time () + 600, "/", $SCRIPT_HOST );
			SetCookie ( "wcity[id]", $v ['id'], time () + 600, "/", $SCRIPT_HOST );
			SetCookie ( "wcity[name]", $v ['name'], time () + 600, "/", $SCRIPT_HOST );
			$_COOKIE ['wcity']['pinyin']='shanghai';
			$_COOKIE ['wcity']['id']='310000';
			$_COOKIE ['wcity']['name']='上海';
			
		}

/*$Sql = 'SELECT * FROM ' . $table_top . 'weather WHERE `AreaID`='.$_COOKIE ['wcity']['id'];
$Rs = $db->getone ( $Sql );
*/
$Weather = getcache($_COOKIE['wcity']['id'], 'today');
$Weather=str_replace ( "@", "\\", $Weather);

$Weather=unserialize($Weather);
$Weather = json_decode($Weather['Weather'],true);

//采集警报
//$GetWeatherJingBao = GetWeatherJingBaoTitle ();
$GetWeatherJingBao = Select_JingBao ();
$time = time ();
if (($time - $GetWeatherJingBao ['0']['update']) > 600||($time - $GetWeatherJingBao ['1']['update']) > 600||($time - $GetWeatherJingBao ['2']['update']) > 600||($time - $GetWeatherJingBao ['3']['update']) > 600) {
	$GetWeatherYuJing = 1;
}
//片区
$PianquCity0=Select_Pianqu_City(1000,12);//华北
$PianquCity1=Select_Pianqu_City(1001,12);//华东
$PianquCity2=Select_Pianqu_City(1002,12);//华南
$PianquCity3=Select_Pianqu_City(1003,12);//华中
$PianquCity4=Select_Pianqu_City(1004,12);//东北
$PianquCity5=Select_Pianqu_City(1005,12);//西北
$PianquCity6=Select_Pianqu_City(1006,12);//西南
//高温低温排序
$PianquHigh=Select_High(8);//高温
$PianquLow=Select_Low(8);//低温
//气候
$QiHou1=Select_QiHou(1,9);//晴天
$QiHou2=Select_QiHou(2,9);//下雨
$QiHou3=Select_QiHou(3,9);//阴天
$QiHou4=Select_QiHou(4,9);//下雪
//$WeatherHot = Select_Hot ( 20 ); //最近关注城市
$WeatherHot_ = Select_Hot ( 'hot',20 ); //最近关注城市
$WeatherHots = Select_Hot ( 'hots',20 ); //最近关注城市
$WeatherHott = Select_Hot ( 'hott',20 ); //最近关注城市
$WeatherHotf = Select_Hot ( 'hotf',20); //最近关注城市
$WeatherHotm = Select_Hot ( 'hotm',20 ); //最近关注城市

//首页友情链接>北京市>北京天气预报

$links=get_links(1);
$daohang="<a href=\"/' title='天气预报查询网\">天气预报查询网</a> >>  <a href=\"/weather_{$_COOKIE [wcity][pinyin]}' title='天气预报查询\">{$_COOKIE [wcity][name]}</a> >>  <strong>{$_COOKIE [wcity][name]}天气预报</strong></a>";
$title = "天气预报-天气预报查询-天气预报查询一周-天气啦";
$keywords="天气预报,天气预报查询,天气预报查询一周";
$description="天气啦(www.tianqi.la)提供全国2401个城市未来3天,5天,7天(一周),10天,15天天气预报查询.想要查看最准的天气预报不来天气啦你去哪?";
define('DEDEINC', ereg_replace("[/\\]{1,}", '/', dirname(__FILE__).'/include' ) );
define('DEDEROOT', ereg_replace("[/\\]{1,}", '/', substr(DEDEINC,0,-8) ) );
define('DEDEDATA', DEDEROOT.'/data');
define('DEDEMEMBER', DEDEROOT.'/member');
define('DEDETEMPLATE', DEDEROOT.'/templets');
include_once DEDEINC.'/common.inc.php';
include_once DEDEINC."/arc.partview.class.php";
$tem=<<<EOT
<ul>{dede:arclist typeid=1 row=2 titlelen=48 orderby='pubdate' }<li><a href="[field:arcurl/]" >[field:title/]</a><span>[field:pubdate function=MyDate('m-d',@me)/]</span></li>{/dede:arclist}</ul>
EOT;
$pv = new PartView();
$pv->SetTemplet($tem,"string");
$dedeone=$pv->GetResult();
$tem=<<<EOT
<ul>{dede:arclist typeid=2 row=2 titlelen=48 orderby='pubdate' }<li><a href="[field:arcurl/]" >[field:title/]</a><span>[field:pubdate function=MyDate('m-d',@me)/]</span></li>{/dede:arclist}</ul>
EOT;
$pv = new PartView();
$pv->SetTemplet($tem,"string");
$dedetwo=$pv->GetResult();
$tem=<<<EOT
<ul>{dede:arclist typeid=3 row=1 titlelen=48 orderby='pubdate' }<li><a href="[field:arcurl/]" >[field:title/]</a><span>[field:pubdate function=MyDate('m-d',@me)/]</span></li>{/dede:arclist}</ul>
EOT;
$pv = new PartView();
$pv->SetTemplet($tem,"string");
$dedethree=$pv->GetResult();
$tem=<<<EOT
<ul>{dede:arclist typeid=4 row=1 titlelen=48 orderby='pubdate' }<li><a href="[field:arcurl/]" >[field:title/]</a><span>[field:pubdate function=MyDate('m-d',@me)/]</span></li>{/dede:arclist}</ul>
EOT;
$pv = new PartView();
$pv->SetTemplet($tem,"string");
$dedefour=$pv->GetResult();
$tem=<<<EOT
{dede:arclist typeid=5 row=4 titlelen=60 orderby='pubdate' } <div class="tq_rboxx1_c"><div class="tq_boxs"><div class="tq_boxd_r"><a href="[field:arcurl/]">[field:title/]</a></div></div></div>{/dede:arclist}
EOT;
$pv = new PartView();
$pv->SetTemplet($tem,"string");
$dedefive=$pv->GetResult();

$WeatherHot=$WeatherHot_;
include template('index');
?>
